


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

public class ContactValidationForm extends ActionForm{
	private AddContactValidationForm ajouter= new AddContactValidationForm();
	private DeleteContactValidationForm supprimer= new DeleteContactValidationForm();
	private ListContactValidationForm lister= new ListContactValidationForm();
	private ModifyContactValidationForm modifier= new ModifyContactValidationForm();
		
		public String nom;
		
		public String prenom;
		
		public String email;
		
		public String adresse;
		
	

	
	
	//get and set methods
		
		
		public String getNom(){
		return nom;}
		
		public void setNom(String newnom){
		this.nom= newnom;}
		
		
		public String getPrenom(){
		return prenom;}
		
		public void setPrenom(String newprenom){
		this.prenom= newprenom;}
		
		
		public String getEmail(){
		return email;}
		
		public void setEmail(String newemail){
		this.email= newemail;}
		
		
		public String getAdresse(){
		return adresse;}
		
		public void setAdresse(String newadresse){
		this.adresse= newadresse;}
		
	
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		String action =(String)request.getAttribute("submit");
		if(action=="Ajouter"){
			return ajouter.validate(mapping, request);
		} 
		if(action=="Supprimer"){
			return supprimer.validate(mapping, request);
		}
		if(action=="Lister"){
			return lister.validate(mapping, request);
		}
		return modifier.validate(mapping, request);
	}	
	
	public void reset(ActionMapping mapping,
					 HttpServletRequest request) {
		String action =(String) request.getAttribute("submit");
		if(action=="Ajouter"){
			ajouter.validate(mapping, request);
		} 
		if(action=="Supprimer"){
			supprimer.validate(mapping, request);
		}
		if(action=="Lister"){
			lister.validate(mapping, request);
		}
		modifier.validate(mapping, request);
	}		
}